Skip to content

fix(seo): trailing slash consistency for hreflang/canonical/sitemap#236

Merged
Mlaz-code merged 1 commit into
mainfrom
fix/trailing-slash-consistency
May 21, 2026
Merged

fix(seo): trailing slash consistency for hreflang/canonical/sitemap#236
Mlaz-code merged 1 commit into
mainfrom
fix/trailing-slash-consistency

Conversation

@Mlaz-code
Copy link
Copy Markdown
Collaborator

Summary

  • Enables trailingSlash: true in Next.js config — Vercel will 308-redirect /en/en/
  • Updates page.tsx to produce trailing-slash canonical and hreflang URLs for all pages
  • Updates sitemap generator to emit trailing-slash <loc> and <xhtml:link> URLs

Root cause

Vercel serves both /en and /en/ as HTTP 200 with identical content (no redirect). Semrush discovers URLs from the sitemap (no trailing slash) and from internal links (with trailing slash), treats them as distinct, and flags the mismatch between the crawled URL and canonical/hreflang tags.

What changes

  • next.config.mjs: added trailingSlash: true
  • page.tsx: all canonical/hreflang/OG URLs now end with /
  • generate-sitemap.mjs: all <loc> and hreflang href URLs now end with /
  • Static export generates en/index.html instead of en.html (directory-based)

Test plan

  • Local build succeeds
  • Verify Vercel 308 redirects /en/en/ after deploy
  • Re-run Semrush crawl to confirm 0 hreflang errors

…map URLs

Semrush flagged 9 hreflang conflicts because Vercel serves both /en and
/en/ as 200 (no redirect), so whichever form tags use conflicts with the
alternate crawled URL.

Fix: enable trailingSlash: true in Next.js config so Vercel redirects
/en → /en/ (308). Update page.tsx and sitemap generator to produce
trailing-slash URLs consistently across:
- <link rel="canonical">
- <link rel="alternate" hreflang>
- sitemap.xml <loc> and <xhtml:link>

Build tested locally — static export now generates directory-based
index.html files (en/index.html instead of en.html).
@Mlaz-code Mlaz-code merged commit 40343bc into main May 21, 2026
@Mlaz-code Mlaz-code deleted the fix/trailing-slash-consistency branch May 21, 2026 19:00
@Mlaz-code
Copy link
Copy Markdown
Collaborator Author

Merge gate (auto-classified): gate=smoke-passed — auto-classified by the gate-log enforcer (9min after merge, no Merge gate: audit comment found). Reviewer agent: please correct if wrong by replying with Merge gate: gate=<correct-word> — <evidence>. The audit log keys on the first such token; your correction overrides this auto-classified guess.

Posted by scripts/gate-log-enforcer.py because instruction-level rules about the gate= template aren't binding (0/N adoption); structural enforcement fills the log either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant